package com.example.rabbitmq.producer.direct.controller;

import com.example.common.model.User;
import com.example.rabbitmq.producer.direct.service.RabbitMQService;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * TODO
 *
 * @author chenzhian
 * @version 0.1.0
 * @since 0.1.0
 */
@RestController
@RequestMapping("/meta/rabbitmq")
public class RabbitMQController {

  @Resource
  private RabbitMQService rabbitMQService;

  /**
   * 发送消息
   *
   * @author java技术爱好者
   */
  @PostMapping("/sendMsg")
  public String sendMsg(@RequestParam(name = "msg") String msg) throws Exception {
    return rabbitMQService.sendMsg(msg);
  }


  /**
   * 发送Object
   *
   * @author java技术爱好者
   */
  @PostMapping("/sendObj")
  public void sendObj(User user) throws Exception {
    rabbitMQService.sendObject(user);
  }
}